package pers.xukai.fullMark.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import pers.xukai.common.constant.response.ResponseResult;
import pers.xukai.fullMark.entity.vo.SaveTodoVo;
import pers.xukai.fullMark.service.TodoService;

/**
 * @author 殷绪凯
 * @since 2022年 11月 29日 15:46
 */
@RestController
@RequestMapping("todoList")
public class TodoListController {

    private final TodoService todoService;

    public TodoListController(TodoService todoService) {
        this.todoService = todoService;
    }

    @ApiOperation("创建Todo")
    @PostMapping("/save")
    public ResponseResult<Object> save(@RequestBody SaveTodoVo todoVo) {
        todoService.save(todoVo);
        return ResponseResult.success();
    }

    @ApiOperation("删除Todo")
    @PostMapping("/delete")
    public ResponseResult<Object> delete(@RequestParam String id) {
        //{"email$task$":{userId:EmailTaskBo}}
        todoService.delete(id);
        return ResponseResult.success();
    }

    @ApiOperation("测试")
    @GetMapping
    private void test(){
        todoService.test();
    }

}
